<!DOCTYPE html>
<html>
<head>
    <title>报废申报</title>
    {% include 'system/common/header.html' %}</head>
<body class="pear-container">
<div class="main-container">
    <form class="layui-form layui-form-pane form-data" action="">
        <input value="{{ device_request.id }}" name="id" hidden>
        <div class="layui-form-item">
            <label class="layui-form-label">申请人ID</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_request.requesterId }}" name="requesterId" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">申请人名称</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_request.requesterName }}" name="requesterName" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">设备名称</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_broken.deviceName }}" name="deviceName" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">设备ID</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_broken.deviceId }}" name="deviceId" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">生产厂家</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_broken.producer }}" name="producer" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">保修信息</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_broken.warranty }}" name="warranty" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">申报于</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_request.create_at }}" name="warranty" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审批于</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_request.audit_at }}" name="warranty" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>

        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">申报说明</label>
            <div class="layui-input-block">
                <textarea name="detail" placeholder="请输入内容" class="layui-textarea"
                          disabled>{{ device_broken.detail }}</textarea>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审核人ID</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_request.auditerId }}" name="requesterId" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">审核人名称</label>
            <div class="layui-input-block">
                <input type="text" value="{{ device_request.auditerName }}" name="requesterName" autocomplete="off"
                       placeholder="请输入" lay-verify="required"
                       class="layui-input" disabled>
            </div>
        </div>
        <div class="layui-form-item layui-form-text">
            <label class="layui-form-label">审核意见</label>
            <div class="layui-input-block">
                <textarea name="detail" placeholder="请输入内容" class="layui-textarea"
                          disabled>{{ device_request.audit_reason }}</textarea>
            </div>
        </div>
    </form>
</div>
</body>
{% include 'system/common/footer.html' %}
<script>
    layui.use(['form', 'table'], function () {
        let form = layui.form

        let $ = layui.$;

        let MODULE_PATH = '/system/approve/'

        form.on('submit(pass)', function (obj) {
            event.preventDefault();
            window.pass(obj)
            window.close()
        })

        form.on('submit(reback)', function (obj) {
            event.preventDefault();
            window.reback(obj)
            window.close()
        })


        window.pass = function (obj) {
            layer.prompt({title: '请填写意见', formType: 2}, function (value, index, elem) {
                let loading = layer.load()
                $.ajax({
                    url: MODULE_PATH + 'pass/tools_pass/' + obj.field['id'],
                    dataType: 'json',
                    type: 'put',

                    data: JSON.stringify({value: value}),
                    success: function (result) {
                        layer.close(loading)
                        if (result.success) {
                            layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
                                parent.layui.table.reload('audit-table')
                            })
                        } else {
                            layer.msg(result.msg, {icon: 2, time: 1000})
                        }
                    }
                })
            })
        }

        window.reback = function (obj) {
            layer.confirm('确定要驳回吗？', {icon: 3, title: '提示'}, function (index) {

                layer.prompt({title: '请填写意见', formType: 2}, function (value, index, elem) {
                    let loading = layer.load()
                    $.ajax({
                        url: MODULE_PATH + 'pass/tools_reback/' + obj.field['id'],
                        dataType: 'json',
                        type: 'put',
                        data: JSON.stringify({value: value}),
                        success: function (result) {
                            layer.close(loading)
                            if (result.success) {
                                layer.msg(result.msg, {icon: 1, time: 1000}, function () {
                                    parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
                                    parent.layui.table.reload('audit-table')
                                })
                            } else {
                                layer.msg(result.msg, {icon: 2, time: 1000})
                            }
                        }
                    })
                })
            })
        }
    });
</script>

</html>